home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
batchut
/
choice17.zip
/
DEMO.BAT
< prev
next >
Wrap
DOS Batch File
|
1990-03-10
|
3KB
|
91 lines
echo off
:start
cls
echo.
echo.
echo ╔══════════════════════════════════════╗
echo ║ C H O I C E ║
echo ║ Demonstration Batch File ║
echo ║ ║
echo ║ by ║
echo ║ Michael L. Wilson ║
echo ╚══════════════════════════════════════╝
REM Below is a menu of choices. ECHO displays the text on the screen
REM The "choice" line consists of the command CHOICE,
REM The prompt you want displayed (in quotes), and a list
REM of letters with no spaces. Since the list consists on ABC,
REM choice will ignore all other letters besides ABC.
echo A...First Choice
echo B...Second Choice
echo C...Third Choice
REM -The acceptable choices-+
REM |
REM ---- The Prompt --+ |
REM | |
REM | |
REM \/ \/
choice "Enter your choice" ABC
REM Notice that the letter A is first in the list. This means that
REM if the user presses A, the system ErrorLevel will be set to 1.
REM The system ErrorLevel will be set to 2 is B is pressed since B
REM is the second in the list.
REM If C is pressed, the system ErrorLevel will be set to 3.
if ErrorLevel 4 goto error
if ErrorLevel 3 goto third
if ErrorLevel 2 goto second
if ErrorLevel 1 goto first
goto error
:first
echo.
echo.
echo You pressed A and got the First Choice option
echo The system ErrorLevel was set to 1
goto next
:second
echo.
echo.
echo You pressed B and got the Second Choice option
echo The system ErrorLevel was set to 2
goto next
:third
echo.
echo.
echo You pressed C and got the Third Choice option
echo The system ErrorLevel was set to 3
goto next
:error
echo.
echo.
echo I'm sorry, something went wrong. Either the system ErrorLevel
echo was set above 3, or below 1. Please try again. If the error
echo persists, please notify Michael L. Wilson.
goto end
:next
echo.
echo.
REM The following line has the Prompt, and the letters list, but
REM has other parmaters as well. The DEFAULT= parameter is
REM used to cause a deafult letter to be chosen when the spacebar
REM or return are pressed. It will also be chosen if the TIMEOUT
REM elapses. The TIMEOUT= parameter will cause the program to
REM automatically choose the default when the specified number
REM of SECONDS has elapsed. If the SHOW paramter is used, the
REM the program will display the acceptable letters, putting the
REM default one in upper case. It will also show the timeout
REM in seconds, and beep if an illegal letter is pressed.
REM
REM The following line, therefore, has Y as its default, and a timeout
REM of 30 seconds. These are displayed since the SHOW option is used.
choice "Do You Wish To Print the Registration Form?" YN DEFAULT=Y TIMEOUT=30 SHOW
if ErrorLevel 3 goto error
if ErrorLevel 2 goto end
if ErrorLevel 1 goto reg
goto error
:reg
if not exist mail.me goto end
copy mail.me prn >nul
:end
echo.
echo Thanks for Trying Choice
echo BYE!